package handling.login.handler;

import client.MapleClient;
import constants.ServerConstants;
import java.io.PrintStream;
import org.apache.mina.core.session.IoSession;
import server.ServerProperties;
import tools.FileoutputUtil;
import tools.HexTool;
import tools.data.LittleEndianAccessor;
import tools.packet.LoginPacket;

public class MapLoginHandler {
    public static void cs( MapleClient c) {
        c.getSession().write(LoginPacket.getcs());
    }
    public static void handlePacket(LittleEndianAccessor slea, MapleClient c) {
        
       //66 00     00 80 55 03 C1 00 00 00 00   V131
        System.out.println();
        byte mapleType = slea.readByte();
        short mapleVersion = slea.readShort();
        
        String maplePatch = String.valueOf(slea.readShort());
         System.out.println("到这里3");
          System.out.println(mapleType);
          System.out.println(mapleVersion);
          System.out.println(maplePatch);
        if ((mapleType != ServerConstants.MAPLE_TYPE) || (mapleVersion != ServerConstants.MAPLE_VERSION) || (!maplePatch.equals(ServerConstants.MAPLE_PATCH))) {
            if (ServerProperties.IsLvkejian()) {
                System.out.print(new StringBuilder().append("mapleType ==  ").append(mapleType).append("   MAPLE_TYPE == ").append(ServerConstants.MAPLE_TYPE).append("\r\n"));
                System.out.print(new StringBuilder().append("mapleVersion ==  ").append(mapleVersion).append("   MAPLE_VERSION == ").append(ServerConstants.MAPLE_VERSION).append("\r\n"));
                System.out.print(new StringBuilder().append("maplePatch ==  ").append(maplePatch).append("    MAPLE_PATCH ==  ").append(ServerConstants.MAPLE_PATCH).append("\r\n"));
            }
             System.err.println("there 30");
            c.getSession().close(true);
            if (ServerProperties.IsLvkejian()) {
                String SendTo = "\r\n时间：" + FileoutputUtil.CurrentReadable_Time() + "  对玩家进行掉线处理 ----10 ";
                FileoutputUtil.packetLog("log\\玩家进行掉线处理.log", SendTo);
            }
        } else {
            System.out.println("到这里2");
            c.getSession().write(LoginPacket.getLoginAUTH());
        }
    }
    public static void handlePacket2(LittleEndianAccessor slea, MapleClient c) {
            c.getSession().write(LoginPacket.getLoginAUTH());
    }
}
